//
//  UPProgressHUD.m
//  Uang Pasti
//
//  Created by 李永彬 on 2025/8/16.
//

#import "UPProgressHUD.h"
#import <SVProgressHUD/SVProgressHUD.h>

// 默认显示时间
static NSTimeInterval const kUPHUDDefaultDisplayDuration = 2.0;

@implementation UPProgressHUD

+ (void)initialize {
    if (self == [UPProgressHUD class]) {
        [self setupDefaultAppearance];
    }
}

#pragma mark - 初始化配置
+ (void)setupDefaultAppearance {
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeNone];
    [SVProgressHUD setMinimumDismissTimeInterval:kUPHUDDefaultDisplayDuration];
    [SVProgressHUD setMaximumDismissTimeInterval:kUPHUDDefaultDisplayDuration];
    
    // 移除所有状态图片
    [SVProgressHUD setSuccessImage:nil];
    [SVProgressHUD setErrorImage:nil];
    [SVProgressHUD setInfoImage:nil];
}

#pragma mark - 显示方法
+ (void)show {
    [SVProgressHUD show];
}

+ (void)showWithStatus:(NSString *)status {
    [SVProgressHUD showWithStatus:status];
}

+ (void)showProgress:(float)progress {
    [SVProgressHUD showProgress:progress];
}

+ (void)showProgress:(float)progress status:(NSString *)status {
    [SVProgressHUD showProgress:progress status:status];
}

#pragma mark - 纯文字状态提示
+ (void)showSuccessWithStatus:(NSString *)status {
    [SVProgressHUD setImageViewSize:CGSizeZero]; // 隐藏图片视图
    [SVProgressHUD showImage:nil status:status]; // 使用nil图片
}

+ (void)showErrorWithStatus:(NSString *)status {
    [SVProgressHUD setImageViewSize:CGSizeZero]; // 隐藏图片视图
    [SVProgressHUD showImage:nil status:status]; // 使用nil图片
}

+ (void)showInfoWithStatus:(NSString *)status {
    [SVProgressHUD setImageViewSize:CGSizeZero]; // 隐藏图片视图
    [SVProgressHUD showImage:nil status:status]; // 使用nil图片
}

#pragma mark - 隐藏方法
+ (void)dismiss {
    [SVProgressHUD dismiss];
}

+ (void)dismissWithDelay:(NSTimeInterval)delay {
    [SVProgressHUD dismissWithDelay:delay];
}

#pragma mark - 配置方法
+ (void)setDefaultMaskType:(SVProgressHUDMaskType)maskType {
    [SVProgressHUD setDefaultMaskType:maskType];
}

+ (void)setDefaultDisplayDuration:(NSTimeInterval)duration {
    [SVProgressHUD setMinimumDismissTimeInterval:duration];
    [SVProgressHUD setMaximumDismissTimeInterval:duration];
}

+ (void)setForegroundColor:(UIColor *)color {
    [SVProgressHUD setForegroundColor:color];
}

+ (void)setBackgroundColor:(UIColor *)color {
    [SVProgressHUD setBackgroundColor:color];
}

+ (void)setFont:(UIFont *)font {
    [SVProgressHUD setFont:font];
}

@end
